Skip to content

feat: added DisabledVault to disable id-cache when noFunctional is set#1072

Merged
jaissica12 merged 8 commits into
developmentfrom
feat/sdke-132-disable-identity-cache-when-no-functional-is-true
Sep 24, 2025
Merged

feat: added DisabledVault to disable id-cache when noFunctional is set#1072
jaissica12 merged 8 commits into
developmentfrom
feat/sdke-132-disable-identity-cache-when-no-functional-is-true

Conversation

@jaissica12

Copy link
Copy Markdown
Contributor

Instructions

  1. PR target branch should be against development
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • Created a new DisabledVault which is used when noFunctional is set true.
  • Added jest and integration tests for it

Testing Plan

  • Was this tested locally? If not, explain why.
  • {explain how this has been tested, and what, if any, additional testing should be done}

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

Comment thread src/mp-instance.ts Outdated
});
const cacheKey = `${mpInstance._Store.storageName}-id-cache`;
if (mpInstance._Store.getNoFunctional()) {
console.log('createIdentityCache: noFunctional is true');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Suggested change
console.log('createIdentityCache: noFunctional is true');

Comment thread test/src/tests-identity.ts Outdated
});

describe('#createIdentityCache', function() {
it('should use LocalStorageVault when noFunctional is false by default', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you aren't really confirming that the vault is or isn't localstorage vs disablevault.

@rmi22186 rmi22186 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor edits. also needs to be rebased against #1063 and logic need to be updated using mpInstance._Store.getPrivacyFlag

Comment thread test/src/tests-identity.ts Outdated
});

describe('#createIdentityCache', function() {
it('should use LocalStorageVault when noFunctional is false by default', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should use LocalStorageVault when noFunctional is false by default', async () => {
it('should save id cache to local storage when noFunctional is false by default', async () => {

Comment thread test/src/tests-identity.ts Outdated
expect(localStorage.getItem('mprtcl-v4_abcdef-id-cache')).to.be.ok;
});

it('should use DisabledVault when noFunctional is true', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should use DisabledVault when noFunctional is true', async () => {
it('should NOT save id cache to local storage when noFunctional is true', async () => {

Comment thread test/src/tests-identity.ts Outdated
});

it('should use DisabledVault when noFunctional is true', async () => {
mParticle.config.noFunctional = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mParticle.config.noFunctional = true;
mParticle.config.launcherOptions = {noFunctional: true};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmi22186 Currently noFunctional / noTargeting is only read from top‑level mParticle.config during init, not from config.launcherOptions that is why mParticle.config.noTargeting = true; works. To use mParticle.config.launcherOptions = {noTargeting: true}; we need to update store to source privacy flags from config.launcherOptions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will need to be updated once you sync this branch with development after the #1064 (review) is merged

Comment thread test/src/tests-identity.ts Outdated
expect(localStorage.getItem('mprtcl-v4_abcdef-id-cache')).not.to.be.ok;
});

it('should use LocalStorageVault when noFunctional is false', async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should use LocalStorageVault when noFunctional is false', async () => {
it('should save id cache to local storage when noFunctional is false', async () => {

Comment thread test/src/vault.spec.ts Outdated
describe('#store', () => {
it('should NOT write to localStorage', () => {
const storageKey = 'test-disabled-store-empty';
const vault = new DisabledVault<Dictionary<Dictionary<string>>>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems overly complicated to use the Dictionary<Dictionary<string>>> type and testObject. maybe just make things simpler and shorter by using testString here and throughout the tests below

Comment thread test/src/vault.spec.ts Outdated
);

vault.purge();
console.log(window.localStorage.getItem(storageKey));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(window.localStorage.getItem(storageKey));

@jaissica12 jaissica12 requested a review from rmi22186 September 19, 2025 20:16
@sonarqubecloud

Copy link
Copy Markdown

@jaissica12 jaissica12 merged commit 8187d72 into development Sep 24, 2025
135 of 149 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 1, 2025
# [2.47.0](v2.46.0...v2.47.0) (2025-10-01)

### Bug Fixes

* SDKE-317 Call deferred methods on Rokt Manager instead of kit ([#1076](#1076)) ([3a0643b](3a0643b))

### Features

* added DisabledVault to disable id-cache when noFunctional is set ([#1072](#1072)) ([8187d72](8187d72))
* added noFunctional in batchUploader to disable offline storage ([#1063](#1063)) ([97dd88a](97dd88a))
* disable session cookie/localStorage when noFunctional is set ([#1070](#1070)) ([edb2e61](edb2e61))
* disable time tracking when noTargeting is set to true ([#1064](#1064)) ([71c891c](71c891c))
@mparticle-automation

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.47.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants